﻿/// <reference path="../Scripts/jquery/jquery-1.4.1.js"/>

var evtTab;
var requesteeUserId;

$(function() {
    //modaladdcontact = $find("modaladdcontact");
    $('div.dje').css('display', 'none');
    $('a[rel="ce"]').toggleClass('cureventtab');
    $('a.eventtab').click(function() {
        switch (this.rel) {
            case 'ce':
                $('a[rel="ce"]').addClass('cureventtab');
                $('a[rel="je"]').removeClass('cureventtab');
                break;
            case 'je':
                $('a[rel="ce"]').removeClass('cureventtab');
                $('a[rel="je"]').addClass('cureventtab');
                break;
        }
        SwitchEventTab(this.rel);
    });

    $('#sendrequestbutton').click(SendContactRequest);

    // image frame
    //$.ifixpng.pixel = '../Content/images/frame/pixel.gif';

    //$('img.frame').imageFrame('roundedTL');
});

function SendContactRequest() {
    var commentel = $('#txtRequestComment');
    commentel.removeClass('commentnotempty');
    var comment = $.trim(commentel.val());
    if ("" == comment) {
        commentel.addClass('commentnotempty');
        commentel.focus();
        return false;
    }
    else {
        $(this).text("加载中");
        $(this).attr('disabled', true);
        $.ajax({
            type: 'POST',
            url: relRootPath + '/Mod/Contact/ContactWebService.asmx/SendContactRequest',
            data: {
                requestorUserId: userid,
                requesteeUserId: requesteeUserId,
                comment: comment
            },
            success: function(data, t, h) {
                $('div#postsend').show();
                $('div#presend').hide();
            },
            error: function(a, b, c) {
                alert('error');
            }
        });
       
        return true;
    }
}

function SwitchEventTab(tab) {
    if (tab == 'ce') {
        $('div.dce').show();
        $('div.dje').hide();
    }
    else if (tab == 'je') {
        $('div.dce').hide();
        $('div.dje').show();
    }
}

function HideButtons() {
    $('div#addcontactbuttons').css('display', 'none');
}

function OpenAddContact(requestee) {
    requesteeUserId = requestee;
    InitializeRequestWindow();
    OpenJqueryDialog();
}

function InitializeRequestWindow() {
    $('#sendrequestbutton').text("确定").attr('disabled', false);
    $('div#presend').show();
    $('div#postsend').hide();
    $('#txtRequestComment').val('');
}